﻿using System;
using BONSAI.BLL;

namespace BONSAI.UI.Pages
{
    public partial class News : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                BindNews();
            }
        }
        private void BindNews()
        {
            var lst = (new NewsBO()).GetAll();
            
            lvwNews.DataSource = lst;
            lvwNews.DataBind();

        }
        protected int CalNumber(int s, int page)
        {
            int n = s / page;

            if (s % page > 0)
                n += 1;

            return n;
        }

        protected void lvwNews_PagePropertiesChanging(object sender, System.Web.UI.WebControls.PagePropertiesChangingEventArgs e)
        {
            DataPager1.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
            BindNews();
        }

    }
}